{extend name="v1/layout/base"}
{block name="content"}
<div class="layui-row layui-col-space15">
  <div class="layui-col-md12">
      <form class="layui-card-body layui-form layui-form-pane">
        <div class="layui-row layui-col-space10 layui-form-item">
          <div class="layui-col-lg8">
            <label class="layui-form-label">栏目名称：</label>
            <div class="layui-input-block">
              <input type="text" name="cate_name" value="{$info.cate_name}" lay-verify="required" lay-reqtext="请输入栏目名称" placeholder="请输入栏目名称" autocomplete="off" class="layui-input">
            </div>
          </div>
        </div>
        <div class="layui-row layui-col-space10 layui-form-item">
          <div class="layui-col-lg8">
            <label class="layui-form-label">栏目标志：</label>
            <div class="layui-input-block">
              <input type="text" name="sign" value="{$info.sign}"  placeholder="请输入栏目标志，不填默认为栏目名称拼音" autocomplete="off" class="layui-input">
            </div>
          </div>
        </div>
        <div class="layui-row layui-col-space10 layui-form-item">
          <div class="layui-col-lg8">
            <label class="layui-form-label">所属上级栏目：</label>
            <div class="layui-input-block">
              <select name="parent_id" id="parent_id" lay-filter="parent_id" lay-verify="required" lay-reqtext="请选择所属配置" lay-search>
                <option value="0">系统平台</option>
                {volist name="$cate_list" id="vo"}
                <option {if condition="$vo['parent_id'] eq $info['cate_id'] || $vo['cate_id'] eq $info['cate_id']" }disabled {/if}  {$info['parent_id']==$vo['cate_id']?'selected':''} value="{$vo.cate_id}">{$vo.prefix}{$vo.cate_name}</option>
                {/volist}
              </select>
            </div>
          </div>
        </div>
        <div class="layui-row layui-col-space10 layui-form-item">
          <div class="layui-col-lg8">
            <label class="layui-form-label">栏目类型：</label>
            <div class="layui-input-block">
              <select name="type" lay-filter="aihao" lay-verify="required" lay-reqtext="请选择栏目类型">
                <option value="">请选择栏目类型</option>
                <option {if condition="$info['type'] eq 1" } selected="selected" {/if} value="1">标志</option>
                <option {if condition="$info['type'] eq 2" } selected="selected" {/if} value="2">图文</option>
                <option {if condition="$info['type'] eq 3" } selected="selected" {/if} value="3">单页</option>
                <option {if condition="$info['type'] eq 5" } selected="selected" {/if} value="5">下载</option>
                <option {if condition="$info['type'] eq 6" } selected="selected" {/if} value="6">留言</option>
              </select>
            </div>
          </div>
        </div>
        <div class="layui-row layui-col-space10 layui-form-item">
          <div class="layui-col-lg8">
            <label class="layui-form-label required layui-block">栏目链接：</label>
            <div class="layui-input-block">
              <input type="text" name="linkurl" id="linkurl" lay-verify="required" lay-reqtext="请输入栏目链接"
                placeholder="请输入栏目链接" value="{$info.linkurl}" class="layui-input">
            </div>
          </div>
        </div>
        <div class="layui-row layui-col-space10 layui-form-item">
          <div class="layui-col-lg8">
            <label class="layui-form-label">排序编号：</label>
            <div class="layui-input-block">
              <input type="number" name="order_id" value="{$info.order_id}"  placeholder="请输入栏目编号" autocomplete="off" class="layui-input">
            </div>
          </div>
        </div>
        <div class="layui-row layui-col-space10 layui-form-item">
          <div class="layui-col-lg8">
            <label class="layui-form-label">是否显示：</label>
            <div class="layui-input-block">
              <input type="radio" name="status" value="1" title="显示" {if condition="$info['status'] eq 1" } checked="checked" {/if}>
              <input type="radio" name="status" value="0" title="不显示" {if condition="$info['status'] eq 0" } checked="checked" {/if}>
            </div>
          </div>
        </div>
        <!-- 底部操作按钮 -->
        <div class="layui-row">
          <div class="layui-col-xs3">&nbsp;</div>
          <div class="layui-col-xs4">
            <input type="hidden" name="act" value="edit" />
            <input type="hidden" name="cate_id" value="{$info.cate_id}" />
            <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" id="infoBackList"><i class="layui-icon">&#xe65c;</i>返回列表</button>
            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit lay-filter="saveBtn"><i class="layui-icon">&#xe609;</i>立即更新</button>
          </div>
          <div class="layui-col-xs5">&nbsp;</div>
        </div>
        <!-- 底部操作按钮结束 -->
      </form>
  </div>
</div>
{/block}
{block name="myScript"}
<script>
  layui.use(['form'], function() {
    var form = layui.form,
      layer = layui.layer,
      $ = layui.$;
    //监听提交
    form.on('submit(saveBtn)', function(data) {
      var data = data.field,
          url = "{:url('/'.config('manage.manage_name').'/'.config('manage.version').'/System/cateSave')}";
      https(url, data, 'post', 1, '正在保存信息').then(res => {
        xkTreeMsg(res.result_msg);
      }, fail => {})
      return false;
    });
    form.on("select(parent_id)", function(data) {
      var parent_id = data.value;
      if (parent_id == 0 || parent_id == '') {
        $("#linkurl").val('');
        $("#linkurl").removeAttr('readonly', 'false');
      } else {
        var url = "{:url('/'.config('manage.manage_name').'/'.config('manage.version').'/System/getCateUrl')}"; // 获取链接
        https(url, {
          parent_id: parent_id
        }, 'post',0,'').then(res => {
          if (res.result_code == 200) {
            $("#linkurl").val(res.resultData.linkurl);
            $("#linkurl").attr('readonly', 'true');
          }
        })
      }
    });
  });
</script>
{/block}
